<?php
require_once 'include.php';

$tempsize = $_GET['size'];
if (isset($_GET['size']) and is_numeric($tempsize) and $tempsize < 60 ){
	$size=$_GET['size'];
}
else{ $size = 30; }




$def_array	= $def_film;
if(isset($_GET['type']) and $_GET['type'] != 'alltype' ){
	$sqltype = mysql_escape_string($_GET['type']);	
}
else{
	$sqltype = '%';
}
if ($sqltype == 'Other'){
	$sql_query=mysql_query("SELECT  ".DATABASE_TABLE_FILE.".fullpath,".DATABASE_TABLE_FILE.".type,".DATABASE_TABLE_FILE.".name, ".DATABASE_TABLE_FILE.".taille, ".DATABASE_TABLE_FILE.".date, ".DATABASE_TABLE_FILE.".server 
			FROM ".DATABASE_TABLE_FILE." WHERE  type like '$sqltype'  ORDER BY date DESC LIMIT $size");
	
}else{
	$sql_query=mysql_query("SELECT ".DATABASE_TABLE_FILE.".fullpath, ".DATABASE_TABLE_FILE.".type,".DATABASE_TABLE_FILE.".name, ".DATABASE_TABLE_FILE.".taille, ".DATABASE_TABLE_FILE.".date, ".DATABASE_TABLE_FILE.".server 
			FROM ".DATABASE_TABLE_FILE." WHERE (".Sql::array_in_where_clause(DATABASE_TABLE_FILE.".name",$def_array).") and type like '$sqltype'  ORDER BY date DESC LIMIT $size");
	
}
print '<?xml version="1.0" encoding= "ISO-8859-1"?>';
?>

<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Search</title>
		<link><?php print "http://".$_SERVER["SERVER_NAME"]."".$_SERVER['PHP_SELF']; ?></link>
		<description>The last films of search</description>
		<language>fr</language> 
		<?php
		while ($query = mysql_fetch_array($sql_query) ){
		?>
		
		<item>
		      <title><?php print htmlspecialchars(stripslashes(File::rm_ext($query['name']))); ?></title>
		      <link><?php print "http://".$_SERVER["SERVER_NAME"]."".$_SERVER['PHP_SELF']."?film=".md5($query['fullpath'])."&amp;idserver=".$query['server'] ?></link>
		      <description>Serveur : <?php print $query['server']; ?> (<?php print date("d M y",$query['date']);?>)</description>
		      <pubDate><?php print date("d M y",$query['date']);?></pubDate>
		</item>
		<?php
		 }
		 ?>
		 
	</channel>
</rss> 